using UnityEngine;

public class PlayerBase : MonoBehaviour
{
	public int tableSide { get; protected set; }

	public MatchController match { get; protected set; }

	public int teamTag { get; protected set; }

	public Ball ball { get; protected set; }

	public AreaMarker areaMarker { get; protected set; }

	public bool isInServe { get; protected set; }

	public virtual void Init(int teamTag, int tableSide, MatchController match)
	{
		this.teamTag = teamTag;
		this.match = match;
		this.tableSide = tableSide;
	}

	public virtual void BallRemovedFromGame()
	{
		ball = null;
		isInServe = false;
	}

	public virtual void StartServe(Ball ball)
	{
	}

	public virtual void ReceiveServe()
	{
		isInServe = false;
	}

	public virtual void ReceiveBall(Ball ball)
	{
	}

	public void HitBall(Vector3 landingPos, float heightAboveNet, float timeToLand, float spinx, float spiny, bool isServe, bool useNormalTime = true, float airResistance = 0f, float rebound = 1f, float racketTimeScale = 1f)
	{
		if (isServe)
		{
			ball.HitServe(landingPos, heightAboveNet, timeToLand, spinx, this, airResistance, rebound, racketTimeScale);
		}
		else
		{
			ball.HitBall(landingPos, heightAboveNet, timeToLand, spinx, spiny, this, useNormalTime, airResistance, rebound, racketTimeScale);
		}
		HitBallParams hitBallParams = default(HitBallParams);
		hitBallParams.ballPosition = ball.position;
		hitBallParams.landingPosition = landingPos;
		hitBallParams.heightAboveNet = heightAboveNet;
		hitBallParams.timeToLand = timeToLand;
		hitBallParams.spinx = spinx;
		hitBallParams.spiny = spiny;
		hitBallParams.isServe = isServe;
		hitBallParams.useNormalTime = useNormalTime;
		hitBallParams.airResistance = airResistance;
		hitBallParams.rebound = rebound;
		hitBallParams.racketTimeScale = racketTimeScale;
		match.OnPlayerHitBall(this, hitBallParams);
		ball = null;
		isInServe = false;
		match.ui.ballFollower.fire.SetActive(false);
	}
}
